//
//  MKUITableViewCellSwipeAction.h
//  MKUI
//  单元格左滑显示的动作按钮，同时封装UITableViewRowAction和UIContextualAction
//  Created by 苏尚进 on 2020/8/24.
//  Copyright © 2020 moon. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN
@class MKUITableViewCellModel;
@class MKUITableViewCellSwipeAction;
typedef NS_ENUM(NSInteger, MKUITableViewCellSwipeActionStyle) {
    MKUITableViewCellSwipeActionStyleNormal = 0,
    MKUITableViewCellSwipeActionStyleDestructive = 1,
};
typedef void (^MKUITableViewCellSwipeActionHandler)(MKUITableViewCellSwipeAction *action, __kindof MKUITableViewCellModel *cellModel);

@interface MKUITableViewCellSwipeAction : NSObject

+ (instancetype)actionWithStyle:(MKUITableViewCellSwipeActionStyle)style title:(nullable NSString *)title handler:(MKUITableViewCellSwipeActionHandler)handler;

@property(nonatomic,readonly) MKUITableViewCellSwipeActionStyle style;
@property(nonatomic,copy,nullable) NSString *title;
@property(nonatomic,copy,readonly) MKUITableViewCellSwipeActionHandler handler;
@property(nonatomic,copy,nullable) UIColor *backgroundColor; // a default background color is set from the action style
@property(nonatomic,copy,nullable) UIImage *image;
@property(nonatomic,assign) BOOL autoCompletion;//是否自动调用完成事件，默认为YES(即UIContextualAction中，将不会调用completionHandler）

- (UIContextualAction *)contextualActionWithCellModel:(MKUITableViewCellModel *)cellModel API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos);
- (UITableViewRowAction *)tableViewRowActionWithCellModel:(MKUITableViewCellModel *)cellModel;
@end

NS_ASSUME_NONNULL_END
